//    Copyright (C) Kherty.  All rights reserved.
using System.Windows.Media.Effects;
using OpenLS.Core.Serialization;

namespace OpenLS.Drawing
{
    public class EffectList : EffectProperties
    {
        private BlurEffect blur;
        private FillOverlayEffect fillOverlay;
        private GlowEffect glow;
        private InnerShadowEffect innerShadow;
        private OuterShadowEffect outerShadow;
        private PresetShadowEffect prstShdw;
        private ReflectionEffect reflection;
        private SoftEdgesEffect softEdge;

        public PresetShadowEffect PresetShadow
        {
            get { return prstShdw; }
            set { prstShdw = value; }
        }

        public GlowEffect Glow
        {
            get { return glow; }
            set { glow = value; }
        }

        public FillOverlayEffect FillOverlay
        {
            get { return fillOverlay; }
            set { fillOverlay = value; }
        }

        public OuterShadowEffect OuterShadow
        {
            get { return outerShadow; }
            set { outerShadow = value; }
        }

        public InnerShadowEffect InnerShadow
        {
            get { return innerShadow; }
            set { innerShadow = value; }
        }

        public ReflectionEffect Reflection
        {
            get { return reflection; }
            set { reflection = value; }
        }

        public BlurEffect Blur
        {
            get { return blur; }
            set { blur = value; }
        }

        public SoftEdgesEffect SoftEdge
        {
            get { return softEdge; }
            set { softEdge = value; }
        }


        public BitmapEffect BitmapEffect(ColorScheme colorScheme)
        {

            {
                if (OuterShadow != null)
                    return OuterShadow.BitmapEffect(colorScheme);
                return null; //\\
            }
        }


        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("effectLst"))
            {
                Blur = c.ReadOptionalElement<BlurEffect>("blur");
                FillOverlay = c.ReadOptionalElement<FillOverlayEffect>("fillOverlay");
                Glow = c.ReadOptionalElement<GlowEffect>("glow");
                InnerShadow = c.ReadOptionalElement<InnerShadowEffect>("innerShdw");
                OuterShadow = c.ReadOptionalElement<OuterShadowEffect>("outerShdw");
                PresetShadow = c.ReadOptionalElement<PresetShadowEffect>("prstShdw");
                Reflection = c.ReadOptionalElement<ReflectionEffect>("reflection");
                SoftEdge = c.ReadOptionalElement<SoftEdgesEffect>("softEdge");
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("effectLst"))
            {
                c.WriteOptionalElement(Blur);
                c.WriteOptionalElement(FillOverlay);
                c.WriteOptionalElement(Glow);
                c.WriteOptionalElement(InnerShadow);
                c.WriteOptionalElement(OuterShadow);
                c.WriteOptionalElement(PresetShadow);
                c.WriteOptionalElement(Reflection);
                c.WriteOptionalElement(SoftEdge);
            }
        }
    }
}